<?php
declare(strict_types=1);
namespace Field;

class StoreVoucherLogConst
{
    public const pk='VoucherLogID';
    public const index=['VoucherLogID'];
	public const fields=['VoucherLogID','VoucherID','UserID','UpdateAt','CreateAt','UseAt','IsUsed','TimeAdd','FromNickID','NickID','ProductID','FromUserID','FromOrderID'];
	public const comment=['VoucherLogID'=>'券记录ID','VoucherID'=>'抵用券ID','UserID'=>'归属会员ID','UpdateAt'=>'更新时间','CreateAt'=>'添加时间','UseAt'=>'使用时间','IsUsed'=>'是否已使用','TimeAdd'=>'增加时间','FromNickID'=>'从哪个NickID转移','NickID'=>'NickID','ProductID'=>'商品ID','FromUserID'=>'来源会员','FromOrderID'=>'来源订单号'];
	/*
    * @Field VoucherLogID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 
    * @Extra auto_increment
    * @Privileges select,insert,update,references
    * @Comment 券记录ID
    */
    public const VoucherLogID = 'VoucherLogID';
    /*
    * @Field VoucherID
    * @Type int(10) unsigned
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 抵用券ID
    */
    public const VoucherID = 'VoucherID';
    /*
    * @Field UserID
    * @Type int(10)
    * @Collation 
    * @Null NO
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 归属会员ID
    */
    public const UserID = 'UserID';
    /*
    * @Field UpdateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra on update CURRENT_TIMESTAMP
    * @Privileges select,insert,update,references
    * @Comment 更新时间
    */
    public const UpdateAt = 'UpdateAt';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 添加时间
    */
    public const CreateAt = 'CreateAt';
    /*
    * @Field UseAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 使用时间
    */
    public const UseAt = 'UseAt';
    /*
    * @Field IsUsed
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 是否已使用
    */
    public const IsUsed = 'IsUsed';
    /*
    * @Field TimeAdd
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 增加时间
    */
    public const TimeAdd = 'TimeAdd';
    /*
    * @Field FromNickID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 从哪个NickID转移
    */
    public const FromNickID = 'FromNickID';
    /*
    * @Field NickID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment NickID
    */
    public const NickID = 'NickID';
    /*
    * @Field ProductID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key MUL
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 商品ID
    */
    public const ProductID = 'ProductID';
    /*
    * @Field FromUserID
    * @Type int(10) unsigned
    * @Collation 
    * @Null YES
    * @Key 
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 来源会员
    */
    public const FromUserID = 'FromUserID';
    /*
    * @Field FromOrderID
    * @Type varchar(20)
    * @Collation utf8mb4_general_ci
    * @Null YES
    * @Key 
    * @Default 
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 来源订单号
    */
    public const FromOrderID = 'FromOrderID';
}

class StoreVoucherLogColumns
{
public  int $VoucherLogID;
   public  int $VoucherID;
   public  int $UserID;
   public  ?string $UpdateAt='';
   public  ?string $CreateAt='';
   public  ?string $UseAt='';
   public  int $IsUsed=0;
   public  int $TimeAdd=0;
   public  int $FromNickID=0;
   public  int $NickID=0;
   public  int $ProductID=0;
   public  int $FromUserID=0;
   public  ?string $FromOrderID='';
	public function toArray():array
	{
		return [
'VoucherLogID'=>$this->VoucherLogID,
    'VoucherID'=>$this->VoucherID,
    'UserID'=>$this->UserID,
    'UpdateAt'=>$this->UpdateAt,
    'CreateAt'=>$this->CreateAt,
    'UseAt'=>$this->UseAt,
    'IsUsed'=>$this->IsUsed,
    'TimeAdd'=>$this->TimeAdd,
    'FromNickID'=>$this->FromNickID,
    'NickID'=>$this->NickID,
    'ProductID'=>$this->ProductID,
    'FromUserID'=>$this->FromUserID,
    'FromOrderID'=>$this->FromOrderID,        ];
	}
}

class StoreVoucherLogRow
{
	public StoreVoucherLogColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'VoucherLogID' => $this->data->VoucherLogID,
        'VoucherID' => $this->data->VoucherID,
        'UserID' => $this->data->UserID,
        'UpdateAt' => $this->data->UpdateAt,
        'CreateAt' => $this->data->CreateAt,
        'UseAt' => $this->data->UseAt,
        'IsUsed' => $this->data->IsUsed,
        'TimeAdd' => $this->data->TimeAdd,
        'FromNickID' => $this->data->FromNickID,
        'NickID' => $this->data->NickID,
        'ProductID' => $this->data->ProductID,
        'FromUserID' => $this->data->FromUserID,
        'FromOrderID' => $this->data->FromOrderID, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new StoreVoucherLogColumns();
        isset($data['VoucherLogID']) && $this->data->VoucherLogID = (int)$data['VoucherLogID'];
           isset($data['VoucherID']) && $this->data->VoucherID = (int)$data['VoucherID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['UpdateAt']) && $this->data->UpdateAt = (string)$data['UpdateAt'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
           isset($data['UseAt']) && $this->data->UseAt = (string)$data['UseAt'];
           isset($data['IsUsed']) && $this->data->IsUsed = (int)$data['IsUsed'];
           isset($data['TimeAdd']) && $this->data->TimeAdd = (int)$data['TimeAdd'];
           isset($data['FromNickID']) && $this->data->FromNickID = (int)$data['FromNickID'];
           isset($data['NickID']) && $this->data->NickID = (int)$data['NickID'];
           isset($data['ProductID']) && $this->data->ProductID = (int)$data['ProductID'];
           isset($data['FromUserID']) && $this->data->FromUserID = (int)$data['FromUserID'];
           isset($data['FromOrderID']) && $this->data->FromOrderID = (string)$data['FromOrderID'];
    }
}
?>